package com.ruoyi.web.controller.grape;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.grape.domain.GrapeStaff;
import com.ruoyi.grape.service.IGrapeStaffService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工管理信息Controller
 * 
 * @author ld
 * @date 2023-11-18
 */
@RestController
@RequestMapping("/grape/staff")
public class GrapeStaffController extends BaseController
{
    @Autowired
    private IGrapeStaffService grapeStaffService;

    /**
     * 查询员工管理信息列表
     */
    @PreAuthorize("@ss.hasPermi('grape:staff:list')")
    @GetMapping("/list")
    public TableDataInfo list(GrapeStaff grapeStaff)
    {
        startPage();
        List<GrapeStaff> list = grapeStaffService.selectGrapeStaffList(grapeStaff);
        return getDataTable(list);
    }

    /**
     * 导出员工管理信息列表
     */
    @PreAuthorize("@ss.hasPermi('grape:staff:export')")
    @Log(title = "员工管理信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GrapeStaff grapeStaff)
    {
        List<GrapeStaff> list = grapeStaffService.selectGrapeStaffList(grapeStaff);
        ExcelUtil<GrapeStaff> util = new ExcelUtil<GrapeStaff>(GrapeStaff.class);
        util.exportExcel(response, list, "员工管理信息数据");
    }

    /**
     * 获取员工管理信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('grape:staff:query')")
    @GetMapping(value = "/{staffId}")
    public AjaxResult getInfo(@PathVariable("staffId") Long staffId)
    {
        return success(grapeStaffService.selectGrapeStaffByStaffId(staffId));
    }

    /**
     * 新增员工管理信息
     */
    @PreAuthorize("@ss.hasPermi('grape:staff:add')")
    @Log(title = "员工管理信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GrapeStaff grapeStaff)
    {
        return toAjax(grapeStaffService.insertGrapeStaff(grapeStaff));
    }

    /**
     * 修改员工管理信息
     */
    @PreAuthorize("@ss.hasPermi('grape:staff:edit')")
    @Log(title = "员工管理信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GrapeStaff grapeStaff)
    {
        return toAjax(grapeStaffService.updateGrapeStaff(grapeStaff));
    }

    /**
     * 删除员工管理信息
     */
    @PreAuthorize("@ss.hasPermi('grape:staff:remove')")
    @Log(title = "员工管理信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{staffIds}")
    public AjaxResult remove(@PathVariable Long[] staffIds)
    {
        return toAjax(grapeStaffService.deleteGrapeStaffByStaffIds(staffIds));
    }
}
